//package org.zhaolei.controller;
//
//import io.minio.MinioClient;
//import io.minio.PutObjectArgs;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestParam;
//import org.springframework.web.bind.annotation.RestController;
//import org.springframework.web.multipart.MultipartFile;
//import org.zhaolei.config.MinioConfig;
//import org.zhaolei.util.CommonUtil;
//import org.zhaolei.util.JsonData;
//
//import java.io.InputStream;
//
//@RestController
//@RequestMapping("/api/test/v1")
//public class TestController {
//
//    @Autowired
//    private MinioConfig minioConfig;
//
//    @Autowired
//    private MinioClient minioClient;
//
//    @PostMapping("/upload")
//    public JsonData testUpload(@RequestParam("file") MultipartFile file) {
//        String fileName = CommonUtil.getFilePath(file.getOriginalFilename());
//        //读取文件流，上传到minio
//        try {
//            InputStream inputStream = file.getInputStream();
//
//            minioClient.putObject(PutObjectArgs.builder().bucket(minioConfig.getBucketName())
//                    .object(fileName)
//                    .stream(inputStream, file.getSize(), -1)
//                    .contentType(file.getContentType())
//                    .build()
//            );
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//
//        String URL = minioConfig.getEndpoint() + "/" + minioConfig.getBucketName() + "/" + fileName;
//
//        return JsonData.buildSuccess(URL);
//    }
//
//}
